INCLUDE(srcs.cmake)

ADD_LIBRARY(imp_static_glibc STATIC ${LIBIMP_SRCS} ${EXT_STATIC_GLIBC_OBJS})
ADD_LIBRARY(imp_shared_glibc SHARED ${LIBIMP_SRCS} ${EXT_SHARED_GLIBC_OBJS})
ADD_LIBRARY(imp_static_uclibc STATIC ${LIBIMP_SRCS} ${EXT_STATIC_UCLIBC_OBJS})
ADD_LIBRARY(imp_shared_uclibc SHARED ${LIBIMP_SRCS} ${EXT_SHARED_UCLIBC_OBJS})
ADD_LIBRARY(imp_shared_glibc_audio_process_aec SHARED ${LIBAUDIOPROCESS_AEC_SRCS} ${EXT_SHARED_GLIBC_AUDIO_OBJS})
ADD_LIBRARY(imp_shared_uclibc_audio_process_aec SHARED ${LIBAUDIOPROCESS_AEC_SRCS} ${EXT_SHARED_UCLIBC_AUDIO_OBJS})
ADD_LIBRARY(imp_shared_glibc_audio_process_agc SHARED ${LIBAUDIOPROCESS_AGC_SRCS} )
ADD_LIBRARY(imp_shared_uclibc_audio_process_agc SHARED ${LIBAUDIOPROCESS_AGC_SRCS} )
ADD_LIBRARY(imp_shared_glibc_audio_process_ns SHARED ${LIBAUDIOPROCESS_NS_SRCS} )
ADD_LIBRARY(imp_shared_uclibc_audio_process_ns SHARED ${LIBAUDIOPROCESS_NS_SRCS} )
ADD_LIBRARY(imp_shared_glibc_audio_process_hpf SHARED ${LIBAUDIOPROCESS_HPF_SRCS} )
ADD_LIBRARY(imp_shared_uclibc_audio_process_hpf SHARED ${LIBAUDIOPROCESS_HPF_SRCS} )
ADD_LIBRARY(imp_shared_glibc_audio_process_hs SHARED ${LIBAUDIOPROCESS_HS_SRCS} ${EXT_SHARED_GLIBC_AUDIO_OBJS})
ADD_LIBRARY(imp_shared_uclibc_audio_process_hs SHARED ${LIBAUDIOPROCESS_HS_SRCS} ${EXT_SHARED_UCLIBC_AUDIO_OBJS})

SET_TARGET_PROPERTIES(imp_static_glibc PROPERTIES
    OUTPUT_NAME "imp"
    ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib-glibc
)

SET_TARGET_PROPERTIES(imp_shared_glibc PROPERTIES
    OUTPUT_NAME "imp"
    LINK_FLAGS "-lpthread -ldl"
    LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib-glibc
)

SET_TARGET_PROPERTIES(imp_static_uclibc PROPERTIES
    OUTPUT_NAME "imp"
    LINK_FLAGS "-muclibc -ldl"
    COMPILE_FLAGS "-muclibc"
    ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib-uclibc
)

SET_TARGET_PROPERTIES(imp_shared_uclibc PROPERTIES
    OUTPUT_NAME "imp"
    LINK_FLAGS "-muclibc -lpthread -ldl"
    COMPILE_FLAGS "-muclibc"
    LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib-uclibc
)

SET_TARGET_PROPERTIES(imp_shared_glibc_audio_process_aec PROPERTIES
    OUTPUT_NAME "audioProcess"
    LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib-glibc
)
SET_TARGET_PROPERTIES(imp_shared_uclibc_audio_process_aec PROPERTIES
    OUTPUT_NAME "audioProcess"
    LINK_FLAGS "-muclibc"
    COMPILE_FLAGS "-muclibc"
    LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib-uclibc
)

SET_TARGET_PROPERTIES(imp_shared_glibc_audio_process_agc PROPERTIES
    OUTPUT_NAME "agc"
    LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib-glibc
)
SET_TARGET_PROPERTIES(imp_shared_uclibc_audio_process_agc PROPERTIES
    OUTPUT_NAME "agc"
    LINK_FLAGS "-muclibc"
    COMPILE_FLAGS "-muclibc"
    LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib-uclibc
)

SET_TARGET_PROPERTIES(imp_shared_glibc_audio_process_ns PROPERTIES
    OUTPUT_NAME "ns"
    LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib-glibc
)
SET_TARGET_PROPERTIES(imp_shared_uclibc_audio_process_ns PROPERTIES
    OUTPUT_NAME "ns"
    LINK_FLAGS "-muclibc"
    COMPILE_FLAGS "-muclibc"
    LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib-uclibc
)

SET_TARGET_PROPERTIES(imp_shared_glibc_audio_process_hpf PROPERTIES
    OUTPUT_NAME "hpf"
    LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib-glibc
)
SET_TARGET_PROPERTIES(imp_shared_uclibc_audio_process_hpf PROPERTIES
    OUTPUT_NAME "hpf"
    LINK_FLAGS "-muclibc"
    COMPILE_FLAGS "-muclibc"
    LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib-uclibc
)

SET_TARGET_PROPERTIES(imp_shared_glibc_audio_process_hs PROPERTIES
    OUTPUT_NAME "hs"
    LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib-glibc
)
SET_TARGET_PROPERTIES(imp_shared_uclibc_audio_process_hs PROPERTIES
    OUTPUT_NAME "hs"
    LINK_FLAGS "-muclibc"
    COMPILE_FLAGS "-muclibc"
    LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib-uclibc
)

INSTALL(TARGETS imp_static_glibc imp_shared_glibc
    ARCHIVE DESTINATION ${LIB_INSTALL_DIR_GLIBC}
    LIBRARY DESTINATION ${LIB_INSTALL_DIR_GLIBC}
)

INSTALL(TARGETS imp_static_uclibc imp_shared_uclibc
    ARCHIVE DESTINATION ${LIB_INSTALL_DIR_UCLIBC}
    LIBRARY DESTINATION ${LIB_INSTALL_DIR_UCLIBC}
)

INSTALL(TARGETS imp_shared_glibc_audio_process_aec
    LIBRARY DESTINATION ${LIB_INSTALL_DIR_GLIBC}
)

INSTALL(TARGETS imp_shared_uclibc_audio_process_aec
    LIBRARY DESTINATION ${LIB_INSTALL_DIR_UCLIBC}
)

INSTALL(TARGETS imp_shared_glibc_audio_process_agc
    LIBRARY DESTINATION ${LIB_INSTALL_DIR_GLIBC}
)

INSTALL(TARGETS imp_shared_uclibc_audio_process_agc
    LIBRARY DESTINATION ${LIB_INSTALL_DIR_UCLIBC}
)

INSTALL(TARGETS imp_shared_glibc_audio_process_ns
    LIBRARY DESTINATION ${LIB_INSTALL_DIR_GLIBC}
)

INSTALL(TARGETS imp_shared_uclibc_audio_process_ns
    LIBRARY DESTINATION ${LIB_INSTALL_DIR_UCLIBC}
)

INSTALL(TARGETS imp_shared_glibc_audio_process_hpf
    LIBRARY DESTINATION ${LIB_INSTALL_DIR_GLIBC}
)

INSTALL(TARGETS imp_shared_uclibc_audio_process_hpf
    LIBRARY DESTINATION ${LIB_INSTALL_DIR_UCLIBC}
)

INSTALL(TARGETS imp_shared_glibc_audio_process_hs
    LIBRARY DESTINATION ${LIB_INSTALL_DIR_GLIBC}
)

INSTALL(TARGETS imp_shared_uclibc_audio_process_hs
    LIBRARY DESTINATION ${LIB_INSTALL_DIR_UCLIBC}
)

ADD_CUSTOM_TARGET(VER ALL DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/core/sys_interface.c)

ADD_CUSTOM_COMMAND(TARGET VER
    PRE_BUILD
    COMMAND touch ${CMAKE_CURRENT_SOURCE_DIR}/core/sys_interface.c
    WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
    COMMENT "Update built time"
)
